/**
 * 获取对象的多层属性的值
 * @param obj
 * @param keys
 * @param defaultValue
 */
export function getProperty(obj: unknown, keys: unknown, defaultValue: unknown) {
    if (typeof obj !== 'object') {
        throw new TypeError('object must be an object')
    }
    if (!Array.isArray(keys)) {
        throw new TypeError('keys must be an array')
    }
    let value = keys.reduce((result: any, key: any) => {
        if (result.hasOwnProperty(key)) {
            return result[key]
        }
    }, obj)
    if (!value) {
        value = defaultValue
    }
    return value
}